var Dog = require('./dog');
var dogObj1 = {
    "name": "Taidi",
    "energy": 4
}
var dogObj2 = {
    "name": "Zangao",
    "energy": 8
}
var dog1 = new Dog(dogObj1);
dog1.on("start", ()=>{
    var setintervalId = setInterval(function(){
        dog1.bark();
        dog1.energy--;
        if(dog1.energy < 0){
            clearInterval(setintervalId);
        }
    },1000)
})
dog1.emit("start");
var dog2 = new Dog(dogObj2);
dog2.on("start", ()=>{
    var setintervalId = setInterval(function(){
        dog2.bark();
        dog2.energy--;
        if(dog2.energy < 0){
            clearInterval(setintervalId);
        }
    },1000)
})
dog2.emit("start");